package com.hk.wms.wmsssoserver.service;

import com.alibaba.csp.sentinel.util.StringUtil;
import com.hk.wms.common.common.JwtUtils;
import com.hk.wms.common.entity.User;
import org.springframework.stereotype.Service;

@Service
public class Memberservice {
    public String login(User user) {
        //获取登录用户名，密码
        String username=user.getUsername();
        String password=user.getPassword();
        //判断用户名密码
        if(StringUtil.isEmpty(username)||StringUtil.isEmpty(password)){
            try {
                throw new Exception("登录失败");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        //登陆成功
        //使用jwt工具类生成token
       String token= JwtUtils.getJwtToken(user.getUsername(),user.getPassword());
        return token;
    }
}
